<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-search" size="mini" @click="handleSearch">搜索</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['device:equipmentRepair:add']">
          新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['device:equipmentRepair:edit']">
          修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="single"
          @click="handleDelete"
          v-hasPermi="['device:equipmentRepair:remove']">
          删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-check"
          size="mini"
          :disabled="single"
          @click="handleSubmit"
          v-hasPermi="['device:equipmentRepair:submit']">
          提交
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['device:equipmentRepair:export']">
          导出
        </el-button>
      </el-col>
      <Tag type="dot" size="default" color="#0fac09">提交</Tag>
      <Tag type="dot" size="default" color="#0323af">审核</Tag>
      <Tag type="dot" size="default" color="#bb0331">验收</Tag>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table
      @scrollBottom="load"
      highlight-current-row
      border
      stripe
      v-loading="loading"
      :cell-style="iCellStyle"
      :data="WxmMstrList"
      @row-click="clickRow"
      :height="tableH"
      :header-cell-style="{ 'text-align': 'center' }">
      <el-table-column label="#" width="40" type="index" align="center" />
      <el-table-column label="维修单号" :show-overflow-tooltip="true" width="120" align="center" prop="wxmDjbh" />
      <el-table-column label="设备代码" :show-overflow-tooltip="true" width="100" align="center" prop="wxmSbdm" />
      <el-table-column label="设备名称" :show-overflow-tooltip="true" width="100" align="center" prop="wxmSbName" />
      <el-table-column label="申请部门" :show-overflow-tooltip="true" width="100" align="center" prop="wxmBmdm">
        <template v-slot="scope">
          <dict-tag :options="deptList" :value="scope.row.wxmBmdm" />
        </template>
      </el-table-column>
      <el-table-column label="申请人员" :show-overflow-tooltip="true" width="100" align="center" prop="wxmSqry" />
      <el-table-column label="停机时间" :show-overflow-tooltip="true" align="center" prop="wxmKssj" width="180" />
      <el-table-column label="维修时间" :show-overflow-tooltip="true" align="center" prop="wxmWxsj" width="180" />
      <el-table-column label="维修工时" :show-overflow-tooltip="true" width="100" align="center" prop="wxmWxgs" />
      <el-table-column label="维修人员" :show-overflow-tooltip="true" width="100" align="center" prop="wxmWxry" />
      <el-table-column label="撤回原因" :show-overflow-tooltip="true" width="100" align="center" prop="wxmNgdesc" />
      <el-table-column label="建立人员" :show-overflow-tooltip="true" width="100" align="center" prop="wxmJlry" />
      <el-table-column label="建立日期" :show-overflow-tooltip="true" align="center" prop="wxmJlrq" width="180" />
      <el-table-column label="分析人员" :show-overflow-tooltip="true" width="100" align="center" prop="wxmFxry" />
      <el-table-column label="分析日期" :show-overflow-tooltip="true" align="center" prop="wxmFxrq" width="180" />
      <el-table-column label="验收人员" :show-overflow-tooltip="true" width="100" align="center" prop="wxmPzry" />
      <el-table-column label="验收日期" :show-overflow-tooltip="true" align="center" prop="wxmPzrq" width="180" />
      <el-table-column label="总停机时间（小时）" :show-overflow-tooltip="true" align="center" prop="wxmZjsj" width="140" />
    </el-table>

    <!--子表Tab-->
    <el-tabs v-model="activeTab">
      <el-tab-pane label="申请及维修内容" name="first">
        <div style="margin-top: 20px">
          <el-form ref="form" :model="wxmMstr" label-width="100px">
            <el-col :span="6">
              <el-form-item label="维修单号" prop="wxmDjbh">
                <el-input v-model="wxmMstr.wxmDjbh" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="申请人员" prop="wxmSqry">
                <el-input v-model="wxmMstr.wxmSqry" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="申请部门" prop="wxmBmdm">
                <el-input v-model="wxmMstr.wxmBmdm" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="设备代码" prop="wxmSbdm">
                <el-input v-model="wxmMstr.wxmSbdm" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="设备名称" prop="wxmSbName">
                <el-input v-model="wxmMstr.wxmSbName" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="维修人员" prop="wxmWxry">
                <el-input v-model="wxmMstr.wxmWxry" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="维修工时" prop="wxmWxgs">
                <el-input v-model="wxmMstr.wxmWxgs" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="建立人员" prop="wxmJlry">
                <el-input v-model="wxmMstr.wxmJlry" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="分析人员" prop="wxmFxry">
                <el-input v-model="wxmMstr.wxmFxry" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="停机时间" prop="wxmKssj">
                <el-input v-model="wxmMstr.wxmKssj" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="维修时间" prop="wxmWxsj">
                <el-input v-model="wxmMstr.wxmWxsj" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="故障原因" prop="wxmGzms">
                <el-input type="textarea" size="mini" v-model="wxmMstr.wxmGzms" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原因处理" prop="wxmClms">
                <el-input type="textarea" size="mini" v-model="wxmMstr.wxmClms" readonly />
              </el-form-item>
            </el-col>
          </el-form>
        </div>
      </el-tab-pane>
      <el-tab-pane label="更换零件清单" name="second">
        <el-table border stripe :data="wxdDetList" :height="tableHChild" :header-cell-style="{ 'text-align': 'center' }">
          <el-table-column label="#" type="index" width="40" align="center" />
          <el-table-column label="部件名称" align="center" prop="wxdPmgg" />
          <el-table-column label="数量" align="center" prop="wxdSl" />
          <el-table-column label="单价(元)" align="center" prop="wxdCgdj" />
          <el-table-column label="金额(元)" align="center" prop="wxdCgje" />
          <el-table-column label="备注" align="center" prop="wxdDesc" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="部门验收" name="third">
        <div style="margin-top: 20px">
          <el-form ref="form" :model="wxmMstr" label-width="100px">
            <el-col>
              <el-form-item label="验收人员" prop="wxmPzry">
                <el-input v-model="wxmMstr.wxmPzry" style="width: 150px" size="mini" readonly />
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="部门验收" prop="wxmYsms">
                <el-input type="textarea" size="mini" style="width: 400px" v-model="wxmMstr.wxmYsms" readonly />
              </el-form-item>
            </el-col>
          </el-form>
        </div>
      </el-tab-pane>
    </el-tabs>

    <!-- 查询对话框   -->
    <el-dialog :title="title" v-model="openSearch" :close-on-click-modal="false" draggable width="420px" append-to-body>
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="88px">
        <el-col :span="24">
          <el-form-item label="建立日期">
            <el-date-picker
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="维修单号" prop="wxmDjbh">
            <el-input
              class="input240"
              v-model="queryParams.wxmDjbh"
              placeholder="请输入维修单号"
              clearable
              size="small"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="设备代码" prop="wxmSbdm">
            <el-input
              class="input240"
              v-model="queryParams.wxmSbdm"
              placeholder="请输入设备名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="设备名称" prop="wxmSbName">
            <el-input
              class="input240"
              v-model="queryParams.wxmSbName"
              placeholder="请输入设备名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="24" style="text-align: center">
          <el-form-item prop="wxmZtbz">
            <el-radio-group v-model="queryParams.wxmZtbz">
              <el-radio label="1">未维修</el-radio>
              <el-radio label="2">已维修</el-radio>
              <el-radio label="">全部</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item style="margin-top: 25px; display: flex; justify-content: flex-end">
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" @click="handleQuery">确认</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-dialog>

    <!-- 添加或修改设备维修单-申请作业对话框 -->
    <el-dialog :title="title" v-model="open" :close-on-click-modal="false" draggable width="720px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="88px">
        <el-col :span="12">
          <el-form-item label="维修单号" prop="wxmDjbh">
            <el-input v-model="form.wxmDjbh" disabled placeholder="流水号生成" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="停机时间" prop="wxmKssj">
            <el-date-picker
              clearable
              size="small"
              v-model="form.wxmKssj"
              type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择停机时间"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申请部门" prop="wxmBmdm">
            <el-select v-model="form.wxmBmdm" style="width: 252px" filterable placeholder="申请部门" clearable disabled>
              <el-option v-for="item in deptList" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申请人员" prop="wxmSqry">
            <el-select v-model="form.wxmSqry" filterable placeholder="申请人员" clearable disabled>
              <el-option v-for="(item, index) in UserOptions" :key="index" :label="item.nickName" :value="item.nickName" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="22">
          <el-form-item label="设备名称" prop="wxmSbdm">
            <el-input disabled style="width: 260px" v-model="form.wxmSbdm" />
            <el-input disabled style="width: 260px" v-model="form.wxmSbName" />
          </el-form-item>
        </el-col>
        <el-col :span="1" style="margin-left: -10px">
          <el-button class="addButton" @click="clickAddButton" type="primary" icon="el-icon-plus" circle />
        </el-col>
        <el-col :span="24">
          <el-form-item label="故障原因" prop="wxmGzms">
            <el-input type="textarea" style="width: 560px" v-model="form.wxmGzms" placeholder="请填写故障原因" />
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 从列表中选择所选部门 -->
    <el-dialog :title="title" v-model="openDevice" :close-on-click-modal="false" draggable width="500px" append-to-body>
      <el-form :model="queryParamsChild" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
        <el-col :span="24">
          <el-form-item label="筛选条件" prop="params.find">
            <el-input v-model="queryParamsChild.params.find" clearable style="width: 370px" size="small" @input="clickAddButton" />
          </el-form-item>
        </el-col>
        <el-table
          highlight-current-row
          border
          stripe
          @scrollBottom="load1"
          v-loading="loading"
          height="300"
          :data="deviceList"
          @row-click="handleDevice"
          :header-cell-style="{ 'text-align': 'center' }">
          <el-table-column label="#" type="index" width="40" align="center" />
          <el-table-column label="设备代码" width="135" prop="bplSbdm" align="center" />
          <el-table-column label="设备名称" :show-overflow-tooltip="true" align="center" prop="bplName" />
          <el-table-column label="设备类型" :show-overflow-tooltip="true" align="center" prop="bplType">
            <template v-slot="scope">
              <dict-tag :options="deviceTypeList" :value="scope.row.bplType" />
            </template>
          </el-table-column>
        </el-table>
        <el-col :span="24">
          <el-form-item style="margin-top: 25px; display: flex; justify-content: flex-end">
            <el-button @click="cancelDevice">取消</el-button>
            <el-button type="primary" @click="openDevice = false">确认</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  listEquipmentRepair,
  getEquipmentRepair,
  delEquipmentRepair,
  addEquipmentRepair,
  updateEquipmentRepair,
  submitEquipmentRepair,
  getWxdDet,
  exportModelRepair,
} from '@/api/device/equipmentRepair'
import { getDeptList, listDept, listEfficientDept } from '@/api/system/dept'
import { userDict } from '@/api/system/user'
import { getEffectiveDeviceType } from '@/api/device/deviceType'
import { listDeviceTrueAll } from '@/api/device/preservePlan'

export default {
  name: 'EquipmentRepair',
  data() {
    return {
      // 遮罩层
      loading: true,
      tableH: (document.body.clientHeight - 130) / 2,
      tableHChild: (document.body.clientHeight - 280) / 2,
      // 默认表
      activeTab: 'first',
      // 选中数组
      rowData: null,
      // 非单个禁用
      single: true,
      // 显示搜索条件
      showSearch: true,
      openSearch: false,
      // 总条数
      total: 0,
      totalAdd: 0,
      // 设备维修单-申请作业表格数据
      WxmMstrList: [],
      wxdDetList: [],
      // 全部部门
      deptList: [],
      // // 有效的部门
      // deptEfficientList: [],
      //用户
      UserOptions: [],
      // 三表所有的设备
      deviceList: [],

      // 设备类型
      deviceTypeList: [],
      // 有效的设备类型
      deviceEfficientTypeList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      openDevice: false,
      // 建立日期时间范围
      dateRange: [new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 60), new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 60)],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 25,
        wxmDjbh: null,
        wxmSbdm: null,
        wxmSbName: null,
        wxmJlrq: null,
        wxmZtbz: '1',
      },
      queryParamsChild: {
        pageNum: 1,
        pageSize: 25,
        params: {
          find: '',
        },
      },
      // 表单参数
      form: {},
      wxmMstr: {},
      // 表单校验
      rules: {
        wxmSbdm: [{ required: true, message: '设备代码不能为空', trigger: 'blur' }],
        wxmBmdm: [{ required: true, message: '申请部门不能为空', trigger: 'blur' }],
        wxmSqry: [{ required: true, message: '申请人员不能为空', trigger: 'blur' }],
        wxmGzms: [{ required: true, message: '故障原因不能为空', trigger: 'blur' }],
      },
    }
  },
  created() {
    // 获取全部设备类型
    getEffectiveDeviceType().then((res) => {
      this.deviceTypeList = res.data
      for (let item of this.deviceTypeList) {
        item.dictLabel = item.dtypeName
        item.listClass = 'default'
        item.dictValue = item.dtypeCode
      }
    })
    // 获取有效设备类型
    getEffectiveDeviceType('0').then((res) => {
      this.deviceEfficientTypeList = res.data
      for (let item of this.deviceEfficientTypeList) {
        item.dictLabel = item.dtypeName
        item.listClass = 'default'
        item.dictValue = item.dtypeCode
      }
    })
    //用户字典
    userDict().then((res) => {
      this.UserOptions = res.data
    })
    // 获取全部部门
    getDeptList().then((res) => {
      this.deptList = res.data
      for (let item of this.deptList) {
        item.dictLabel = item.deptName
        item.listClass = 'default'
        item.dictValue = item.deptId + ''
      }
    })
    // // 获取有效部门
    // listEfficientDept('0').then((res) => {
    //   this.deptEfficientList = res.data
    //   for (let item of this.deptEfficientList) {
    //     item.dictLabel = item.deptName
    //     item.listClass = 'default'
    //     item.dictValue = item.deptId + ''
    //   }
    // })
    this.getList()
  },
  methods: {
    /** 颜色事件 */
    iCellStyle: function ({ row, column, rowIndex, columnIndex }) {
      //提交
      if (row.wxmZtbz == '1' && row.wxmTjflag == '1') {
        return 'padding:0px 0;color:#0fac09'
      }
      //审核
      else if (row.wxmZtbz == '2' && row.wxmTjflag == '1') {
        return 'padding:0px 0;color:#0323af'
      }
      //验收
      else if (row.wxmZtbz == '4' && row.wxmTjflag == '1') {
        return 'padding:0px 0;color:#bb0331'
      }
    },
    /** 查询设备维修单-申请作业列表 */
    getList() {
      this.loading = true
      this.queryParams.params = {}
      if (null != this.dateRange && '' != this.dateRange) {
        this.queryParams.params['beginWxmJlrq'] = this.moment(this.dateRange[0]).format('YYYY-MM-DD HH:mm:ss')
        this.queryParams.params['endWxmJlrq'] = this.moment(this.dateRange[1]).format('YYYY-MM-DD HH:mm:ss')
      }
      this.queryParams.pageNum = 1
      listEquipmentRepair(this.queryParams).then((response) => {
        this.WxmMstrList = []
        this.WxmMstrList = this.WxmMstrList.concat(response.rows)
        this.total = response.total
        this.loading = false
        this.wxdDetList = []
        this.wxmMstr = {}
        if (this.rowData == null) {
          this.clickRow(this.WxmMstrList[0])
        }
      })
    },

    //load
    load() {
      if (this.queryParams.pageNum < Math.ceil(this.total / this.queryParams.pageSize)) {
        this.queryParams.pageNum++
        listEquipmentRepair(this.queryParams).then((response) => {
          this.WxmMstrList = this.WxmMstrList.concat(response.rows)
          this.total = response.total
          this.loading = false
        })
      }
      return 0
    },
    load1() {
      if (this.queryParamsChild.pageNum < Math.ceil(this.totalAdd / this.queryParamsChild.pageSize)) {
        this.queryParamsChild.pageNum++
        listDeviceTrueAll(this.queryParamsChild).then((res) => {
          this.deviceList = this.deviceList.concat(res.rows)
          this.totalAdd = res.total
        })
      }
      return 0
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.openSearch = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        wxmId: null,
        wxmDjbh: null,
        wxmSbdm: null,
        wxmSbName: null,
        wxmBmdm: null,
        wxmSqry: null,
        wxmKssj: new Date(),
        wxmGzms: null,
        wxmClms: null,
        wxmYsms: null,
        wxmWxry: null,
        wxmWxgs: null,
        wxmWxsj: null,
        wxmTjflag: null,
        wxmZtbz: null,
        wxmNgdesc: null,
        wxmJlry: null,
        wxmJlrq: null,
        wxmFxry: null,
        wxmFxrq: null,
        wxmPzry: null,
        wxmPzrq: null,
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.WxmMstrList = []
      this.getList()
      this.openSearch = false
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    clickRow(row) {
      this.single = row == null || row.wxmZtbz != '1' || row.wxmTjflag != '0'
      if (row != null) {
        this.rowData = row
        this.getWxmDet(row.wxmId, row.wxmDjbh)
      }
    },
    // rowClick 点击获取选中的头表和关联的明细
    getWxmDet(wxmId, wxmDjbh) {
      getEquipmentRepair(wxmId).then((response) => {
        this.wxmMstr = response.data
      })
      this.getWxd(wxmDjbh)
    },
    //根据 订单编号 获取明细数据
    getWxd(wxmDjbh) {
      getWxdDet(wxmDjbh).then((res) => {
        this.wxdDetList = res.data
      })
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.form.wxmBmdm = this.$store.state.user.deptId + ''
      this.form.wxmSqry = this.$store.state.user.nickName
      this.open = true
      this.title = '添加设备维修单-申请作业'
    },
    /** 修改按钮操作 */
    handleUpdate() {
      this.reset()
      const wxmId = this.rowData.wxmId
      getEquipmentRepair(wxmId).then((response) => {
        this.form = response.data
        this.open = true
        this.title = '修改设备维修单-申请作业'
      })
    },
    handleSearch() {
      this.reset()
      this.title = '查询设备维修单-申请作业'
      this.openSearch = true
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.form.wxmKssj = this.moment(this.form.wxmKssj).format('YYYY-MM-DD HH:mm:ss')
          if (this.form.wxmId != null) {
            updateEquipmentRepair(this.form).then((response) => {
              this.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            this.form.wxmTjflag = 1
            addEquipmentRepair(this.form).then((response) => {
              this.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete() {
      const wxmId = this.rowData.wxmId
      this.$confirm('是否确认删除维修单号【' + this.rowData.wxmDjbh + '】的数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(function () {
          return delEquipmentRepair(wxmId)
        })
        .then(() => {
          this.getList()
          this.msgSuccess('删除成功')
        })
        .catch(() => {})
    },
    /** 提交按钮操作 */
    handleSubmit() {
      const wxmId = this.rowData.wxmId
      this.$confirm('是否确认提交维修单号【' + this.rowData.wxmDjbh + '】的数据项?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'success',
      })
        .then(function () {
          return submitEquipmentRepair(wxmId)
        })
        .then(() => {
          this.getList()
          this.msgSuccess('提交成功')
        })
        .catch(() => {})
    },
    /** 添加界面点击加号事件 */
    clickAddButton() {
      this.queryParamsChild.pageNum = 1
      listDeviceTrueAll(this.queryParamsChild).then((res) => {
        this.deviceList = res.rows
        this.totalAdd = res.total
      })
      this.openDevice = true
    },
    handleDevice(row) {
      this.form.wxmSbdm = row.bplSbdm
      this.form.wxmSbName = row.bplName
    },
    cancelDevice() {
      this.form.wxmSbdm = ''
      this.form.wxmSbName = ''
      this.openDevice = false
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$confirm('是否确认导出所有设备维修作业数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.exportLoading = true
          return exportModelRepair(queryParams)
        })
        .then((response) => {
          this.download(response.msg)
          this.exportLoading = false
        })
        .catch(() => {})
    },
  },
}
</script>

<style lang="scss" scoped></style>
